package de.hpi.generator.config;

import de.hpi.generator.model.Column;
import de.hpi.generator.model.ColumnsCollection;
import de.hpi.generator.model.Database;
/**
 *
 * @author Michael Wolowyk
 */

public class ConfigValidator {

    /**
     * Checks if loop dependency between inclusion dependencies exists
     * 
     * @param aDatabase  
     * @throws LoopDependencyException
     */
    public static void findDependencyLoop(Database aDatabase) throws LoopDependencyException {
        ColumnsCollection aAllColumns = aDatabase.getAllColumns();
        for (Column aColumn : aAllColumns) {
            if (aColumn.isDependentOn(aColumn)) {
                throw new LoopDependencyException(aColumn.getOwner().getName()
                        + ":" + aColumn.getName() + " contains loop dependency");
            }
        }
    }
}
